package com.richpencil.config.datasource;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfigurer {


/*
    @Bean(name = "DataSourceK3")
    @ConfigurationProperties(prefix = "spring.datasource.k3")
    public DataSource k3DataSource() {
        return DataSourceBuilder.create().type(DruidDataSource.class).build();
    }

    @Bean(name = "DataSourceFL")
    @ConfigurationProperties(prefix = "spring.datasource.fl")
    public DataSource flDataSource() {
        return DataSourceBuilder.create().type(DruidDataSource.class).build();
    }
*/

    @Primary
    @Bean(name = "DataSourcePrimary")
    @ConfigurationProperties(prefix = "spring.datasource.primary")
    public DataSource primaryDataSource() {
        return DataSourceBuilder.create().type(DruidDataSource.class).build();
    }

}
